import request from '@/utils/request';
import IS_MOCK, { BASE_URL } from '@/utils/url';

//获取设备列表
export async function getMakerList(params) {
  const { pagination, formData } = params;
  return IS_MOCK
    ? request(`/api/monitor/getMakerList`, {
        method: 'post',
        data: {
          size: '10',
          start: '1',
          ...params.formData,
        },
      })
    : request(
        `${BASE_URL}/crossSection/getMarkerList?size=${pagination.size}&start=${pagination.start}`,
        {
          method: 'post',
          data: {
            ...formData,
          },
        },
      );
}

export async function addNewMonitor(params) {
  return IS_MOCK
    ? request('/api/monitor/insert', {
        method: 'post',
        data: params,
      })
    : request(`${BASE_URL}/crossSection/insert`, {
        method: 'post',
        data: params,
      });
}

export async function updateMonitor(params) {
  return IS_MOCK
    ? request('/api/monitor/update', {
        method: 'post',
        data: params,
      })
    : request(`${BASE_URL}/crossSection/update`, {
        method: 'post',
        data: params,
      });
}

export async function deleteMonitor(params) {
  return IS_MOCK
    ? request('/api/monitor/delete', {
        method: 'post',
        data: params,
      })
    : request(`${BASE_URL}/crossSection/delete`, {
        method: 'post',
        data: params,
      });
}
